"""Ensure that the list of libraries (presumably provided as a
command option 'libraries') is valid, i.e. it is a list of
2-tuples, where the tuples are (library_name, build_info_dict).
Raise DistutilsSetupError if the structure is invalid anywhere;
just returns otherwise."""
if type(libraries) is not ListType:
raise DistutilsSetupError, "'libraries' option must be a list of tuples"
for lib in libraries:
if type(lib) is not TupleType and len(lib) != 2:
raise DistutilsSetupError, "each element of 'libraries' must a 2-tuple"
if type(lib[0]) is not StringType:
raise DistutilsSetupError, "first element of each tuple in 'libraries' " + 'must be a string (the library name)'
if ('/' in lib[0] or os.sep != '/') and os.sep in lib[0]:
raise DistutilsSetupError, ("bad library name '%s': " + 'may not contain directory separators') % lib[0]
if type(lib[1]) is not DictionaryType:
raise DistutilsSetupError, "second element of each tuple in 'libraries' " + 'must be a dictionary (build info)'
continue
def get_library_names(self):
if not self.libraries:
return None
lib_names = []
for lib_name, build_info in self.libraries:
lib_names.append(lib_name)
return lib_names
def get_source_files(self):
self.check_library_list(self.libraries)
filenames = []
for lib_name, build_info in self.libraries:
sources = build_info.get('sources')
if sources is None or type(sources) not in (ListType, TupleType):
raise DistutilsSetupError, "in 'libraries' option (library '%s'), 'sources' must be present and must be a list of source filenames" % lib_name
filenames.extend(sources)
return filenames
def build_libraries(self, libraries):
for lib_name, build_info in libraries:
sources = build_info.get('sources')
if sources is None or type(sources) not in (ListType, TupleType):
raise DistutilsSetupError, ("in 'libraries' option (library '%s'), " + "'sources' must be present and must be " + 'a list of source filenames') % lib_name